<template>
  <div class="photoinfo-container">
    <h3>{{msg.title}}</h3>
    <p class="subtitle">
      <span>发表时间：{{msg.add_time | dataFormat('YYYY-MM-DD HH:mm:ss')}}</span>
      <span>点击：{{msg.click}}次</span>
    </p>

    <hr>

    <!-- 缩略图区域 -->
      <vue-preview :slides="slide1"></vue-preview>
    <!-- 图片内容区域 -->

    <div class="content" v-html="msg.content"></div>

    <!-- 评论组件 -->
    <cmt-box :id="id"></cmt-box>
  </div>
</template>

<script>
import comment from "../subcomponents/comment.vue";
export default {
  data() {
    return {
      id: this.$route.params.id,
      msg: {},
      slide1: []
    };
  },
  components: {
    "cmt-box": comment
  },

  methods: {
    getPhotoInfo() {
      this.$http.get("api/getimageInfo/" + this.id).then(res => {
        if (res.body.status === 0) {
          this.msg = res.body.message[0];
        }
      });
    },
    getPhotos() {
      this.$http.get("api/getthumimages/" + this.id).then(res => {
        if (res.body.status === 0) {
          res.body.message.forEach(item => {
            item.w = 300;
            item.h = 300;
            item.msrc = item.src;
            this.slide1.push(item);
          });
        }
      });
    },
    handleClose() {
      console.log("close event");
    }
  },

  created() {
    this.getPhotoInfo();
    this.getPhotos();
  }
};
</script>

<style lang='less' scoped>
.photoinfo-container {
  padding: 3px;
  h3 {
    color: lightskyblue;
    font-size: 16px;
    text-align: center;
    padding: 10px 0;
  }
  .subtitle {
    display: flex;
    justify-content: space-between;
  }
  .content {
    font-size: 14px;
    line-height: 30px;
  }
}
// 此处想给缩略图设置样式，但是没有效果
.preview {
  img {
    width: 100px;
    height: 100px;
  }
}
// .my-gallery {
//     background-color: #fff;
//     figure {
//         display: inline-block;
//     }
//   img {
//     width: 30px;
//     height: 30px;
//   }
// }
</style>
